using IQIGame.Onigao.Game;
using IQIGame.Onigao.GamePlay;

namespace IQIGame.Onigao.Logic
{
    /// <summary>
    /// 移除实体
    /// 参数：1：实体tag（可选）
    /// </summary>
    public class ExecRemoveEntity : BaseServiceExecution
    {
        public override void Execute(LevelRegion region, LevelPlayer player)
        {
            var config = _config as ExecParamRemoveEntity;
            var entities = ListPool<LevelEntity>.Get();
            if (!LgLevelEntityUtil.GetEntitiesByDynCfgKeys(region, triggerEntity, config.tagOrMcid, entities, true))
            {
                ListPool<LevelEntity>.Put(entities);
                return;
            }

            region.RemoveEntitys(entities);
            region.UpdateRemoveEntities(player, entities);

            ListPool<LevelEntity>.Put(entities);
        }
    }
}

